import { cloudService } from './index'
import { IAccount } from '@/types/auth.ts'

export const queryAccountApi = (): Promise<IAccount[]> =>
  cloudService({
    url: '/admin-service/account',
    method: 'get'
  })

export const registerAccountApi = (account: IAccount): Promise<boolean> =>
  cloudService({
    url: '/admin-service/account',
    method: 'post',
    data: account
  })

export const deleteAccountApi = (id: number): Promise<boolean> =>
  cloudService({
    url: `/admin-service/account/${id}`,
    method: 'delete'
  })

export const updateAccountPasswordApi = (id: number,
  oldPassword: string, newPassword: string): Promise<boolean> =>
  cloudService({
    url: `/admin-service/account/password/${id}`,
    method: 'put',
    params: { oldPassword, newPassword }
  })
